<template>
  <div id="dictEdit">
    <dict-add-and-edit-table @submitDictInfo="submitDictInfo" :dictInfo="dictInfo"/>
  </div>
</template>

<script>
import { findByIdDict,updateDict } from '@/assets/request/api'
import dictAddAndEditTable from './dictAddAndEditTable.vue'
export default {
  components: { dictAddAndEditTable },
  name: "dictEdit",
  props: ["editData"],
  data() {
    return {
      dictInfo: {}
    }
  },
  methods: {
    submitDictInfo(dictInfo) {
      updateDict(dictInfo).then(res => {
        this.$message({
          message: '更新成功',
          type: 'success'
        });
        this.$router.push({'name':"dictManagement"})
      }).catch(err => {
        this.$message({
          message: err.message,
          type: 'error'
        });
      })
    },
    async findByIdDict(dictDetailId) {
      await findByIdDict(dictDetailId).then(res => {
        this.dictInfo = res.data
      }).catch(err => {
        this.$message({
          message: err.message,
          type: 'error'
        });
      })
    }
  },
  created() {
    this.findByIdDict(this.$route.params.id)
  },
}
</script>

<style lang="scss" scoped>

</style>